<?php use_stylesheets_for_form($form) ?>
<?php use_javascripts_for_form($form) ?>
<!--BOTON cerrado + condicion de actualización-->
<button type="button" class="slideDer-cerrar" onclick="javascritp:LoadUser('<?php echo url_for('dashboard/'.$parent)?>','<?php echo $idUser ?>','');MenuClose();"></button>
<!--Division del formulario-->
<div class="jwj-callcenter-div"></div>
<!--Formulario con declaración de class y de ID Formulario-->
<form class="jwj-callcenter-form" id="myForm" action="<?php echo url_for('llamadaServicio/'.($form->getObject()->isNew() ? 'create' : 'update').(!$form->getObject()->isNew() ? '?id='.$form->getObject()->getId() : '')) ?>" method="post" <?php $form->isMultipart() and print 'enctype="multipart/form-data" ' ?>>
<?php if (!$form->getObject()->isNew()): ?>
<input type="hidden" name="sf_method" value="put" />
<?php endif; ?>
  <table>
    <tfoot>
    </tfoot>
    <tbody>
      <?php echo $form->renderGlobalErrors() ?>
      <tr>
        <th><?php echo $form['periodicidad']->renderLabel() ?></th>
        <td>
          <?php echo $form['periodicidad']->renderError() ?>
          <?php echo $form['periodicidad'] ?>
        </td>
      </tr>
      <tr>
        <th><?php echo $form['nota']->renderLabel() ?></th>
        <td>
          <?php echo $form['nota']->renderError() ?>
          <?php echo $form['nota'] ?>
        </td>
      </tr>
    </tbody>
  </table>
<!--Campo Oculto de evio de variable de ID del usuario-->
<input type="hidden" name="idUser" value='<?php echo $idUser ?>'/>

<!--Division del formulario-->
<div class="jwj-callcenter-div"></div>

<!--Lista de Acciones del Formulario-->
<div id="jwj-callcenter-action">
           <?php echo $form->renderHiddenFields(false) ?>
          <?php if (!$form->getObject()->isNew()): ?>
          <?php //echo link_to('Delete', 'formulario/deleteDireccion?id='.$form->getObject()->getId(), array('method' => 'delete', 'confirm' => 'Are you sure?')) ?>
          <button type="button" id="jwj-callcenter-form-delete" class="jwj-callcenter-form-red" title="Listar" onclick="javascript:LoadUserDelete('<?php echo url_for('nota/delete'); ?>',<?php echo $idUser; ?>,'<?php echo "id=".$form->getObject()->getId(); ?>','#slideDer-intConten');" >Eliminar</button>
          <?php endif; ?>
          <input type="submit" value="Save" id="jwj-callcenter-form-save" class="jwj-callcenter-form-red"/>
          
          <button type="button" id="AddBoton-Cerrar" title="Cerrar" class="AddBotonTools" onclick="javascritp:LoadUser('<?php echo url_for('dashboard/'.$parent)?>','<?php echo $idUser ?>','');MenuClose();">Cerrar</button>
</div>

</form><!--Ejecucion del Formulario por Jquery para evitar recarga-->
<script type="text/javascript">
    <?php
    //Impresion de Funcion para la recarga de la pagina cuando se ingrese un nuevo registro
    if (!$form->getObject()->isNew())
    echo "\tLoadUser('".url_for('dashboard/'.$parent)."','".$idUser."');"; ?>
// prepare the form when the DOM is ready
$(document).ready(function() {
    var options = {
        target:        '#slideDer-intConten',   // target element(s) to be updated with server response
        beforeSubmit:  showRequest,  // pre-submit callback
        success:       showResponse  // post-submit callback

        // other available options:
        //url:       url         // override for form's 'action' attribute
        //type:      type        // 'get' or 'post', override for form's 'method' attribute
        //dataType:  null        // 'xml', 'script', or 'json' (expected server response type)
        //clearForm: true        // clear all form fields after successful submit
        //resetForm: true        // reset the form after successful submit

        // $.ajax options can be used here too, for example:
        //timeout:   3000
    };

    // bind form using 'ajaxForm'
    $('#myForm').ajaxForm(options);
});

// pre-submit callback
function showRequest(formData, jqForm, options) {
    // formData is an array; here we use $.param to convert it to a string to display it
    // but the form plugin does this for you automatically when it submits the data
    var queryString = $.param(formData);

    // jqForm is a jQuery object encapsulating the form element.  To access the
    // DOM element for the form do this:
    // var formElement = jqForm[0];

    //alert('About to submit: \n\n' + queryString);

    // here we could return false to prevent the form from being submitted;
    // returning anything other than false will allow the form submit to continue
    return true;
}

// post-submit callback
function showResponse(responseText, statusText, xhr, $form)  {
    // for normal html responses, the first argument to the success callback
    // is the XMLHttpRequest object's responseText property

    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'xml' then the first argument to the success callback
    // is the XMLHttpRequest object's responseXML property

    // if the ajaxForm method was passed an Options Object with the dataType
    // property set to 'json' then the first argument to the success callback
    // is the json data object returned by the server

//    alert('status: ' + statusText + '\n\nresponseText: \n' + responseText +
//        '\n\nThe output div should have already been updated with the responseText.');
}
</script>